<template>
    <div>
        <el-table
            ref="customerTable"
            :data="tableData"
            stripe
            style="width: 100%"
            @selection-change="getSelectVal"
        >
            <el-table-column type="selection" width="55" align="center" />
            <el-table-column
                type="index"
                label="序号"
                width="55"
                align="center"
            />
            <el-table-column prop="deptCode" label="部门编码">
                <template slot-scope="scope">{{
                    scope.row.deptCode || "--"
                }}</template>
            </el-table-column>
            <el-table-column prop="deptName" label="部门名称">
                <template slot-scope="scope">{{
                    scope.row.deptName || "--"
                }}</template>
            </el-table-column>
            <el-table-column prop="orderNum" label="排序">
                <template slot-scope="scope">{{
                    scope.row.orderNum || "--"
                }}</template>
            </el-table-column>
            <el-table-column prop="email" label="邮箱">
                <template slot-scope="scope">{{
                    scope.row.email || "--"
                }}</template>
            </el-table-column>
            <el-table-column prop="status" label="状态">
                <template slot-scope="scope">
                    <el-tag v-if="scope.row.status === '0'" type="success"
                        >正常</el-tag
                    >
                    <el-tag v-if="scope.row.status === '1'" type="danger"
                        >异常</el-tag
                    >
                </template>
            </el-table-column>
            <el-table-column prop="phone" label="手机"
                ><template slot-scope="scope">{{
                    scope.row.phone || "--"
                }}</template></el-table-column
            >
        </el-table>
        <el-pagination
            class="pagination mt10"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            :page-sizes="[10, 20, 30, 40]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
            background
        >
        </el-pagination>
    </div>
</template>

<script>
import { listDept } from "@/api/system/dept";
export default {
    data() {
        return {
            tableData: [],
            currentPage: 1, //当前页
            pageSize: 10, //每页条数
            total: 0,
        };
    },
    methods: {
        //分页器size
        handleSizeChange(val) {
            this.pageSize = val;
            this.getDataList();
        },
        //分页器当前页
        handleCurrentChange(val) {
            this.currentPage = val;
            this.getDataList();
        },
        getSelectVal(val) {
            this.$emit("getSelectVal", val);
        },
        getDataList() {
            let level = 2;
            listDept({ level }).then((res) => {
                this.tableData = res.data;
                this.total = res.data.length;
            });
        },
    },
    mounted() {
        this.getDataList();
    },
};
</script>

<style></style>
